m,n,k=map(int,input().split())

pr=int(input())
price_list=[]
for i in range(pr):
    price_list.append(int(input()))


print(price_list)
#先满减+后打折

def jian_zhe(price,m,n):
    price_hou=price
    alls=0
    while price_hou>=100 and m>0:
        price_hou = price_hou-int(price_hou/100)*10
        m-=1
        alls+=1
    if n>1:
        price_hou=int(price_hou*0.92)
        alls+=1
    return [price_hou,alls]
#先打折、后满减
def zhe_jian(price,m,n):
    price_hou=price
    alls=0
    if n>1:
        price_hou=int(price_hou*0.92)
        alls+=1
    while price_hou>=100 and m>0:
        price_hou = price_hou - int(price_hou/100)*10
        m-=1
        alls+=1
    return [price_hou,alls]




#先打折后无门槛
def zhe_wu(price,n,k):
    price_hou= price
    alls=0
    if n>1:
        price_hou=int(price_hou *0.92)
        alls+=1
    while price_hou>0 and k>0:
        price_hou-=5
        k-=1
        alls+=1
    return [price_hou,alls]



#先满减后无门槛

def jian_wu(price,m,k):
    price_hou= price
    alls=0
    while price_hou >=100 and m>0:
        price_hou = price_hou -int(price_hou/100)*10
        m-=1
        alls+=1
    while price_hou>0 and k>0:
        price_hou -=5
        k-=1
        alls += 1
    return [price_hou,alls]

price_list1=[]
for i in range(pr):
    if m == 0 :
        temp=zhe_wu(price_list[i],n,k)
        price_list1.append(temp)
    elif n==0:
        price_list1.append(jian_wu(price_list[i],m,k))
    elif k==0:
        temp1=jian_zhe(price_list[i],m,n)
        temp2=zhe_jian(price_list[i],m,n)
        list1=[]
        list1.append(temp1)
        list1.append(temp1)
        list1.sort(key= lambda x :(x[0],x[1]))
        price_list1.append(list1[0])
    else:
        list1=[]
        list1.append(zhe_wu(price_list[i],n,k))
        print(list1)
        list1.append(jian_wu(price_list[i],m,k))
        print(list1)
        list1.append(jian_zhe(price_list[i],m,n))
        print(list1)
        list1.append(zhe_jian(price_list[i],m,n))
        print(list1)
        list1.sort(key = lambda x:(x[0],x[1]))
        print(list1)
        price_list1.append(list1[0])
for i in range(pr):
    print(price_list1[i][0],price_list1[i][1])


